<?php
namespace Hive\Ressource\Source;
/**
 * Source Type Object.
 *
 * It represant the type of Source meaning the source it self.
 *
 * @author Xavier VILAIN
 * @package Hive\Ressource\Source
 *
 * @property string	$type			Id of the Source
 * @property string	$label			Source name
 * @property bool	$standard		Is a standard type (can't be deleted)
 * @property bool	$active			Is an active type (can be selected)
 */
class Type  extends \Fox\Object {

	/**
	 * Reverse Link to Sources
	 * @var string
	 */
	const LINK_SOURCES = 'sources';
	
	/**
	 * Render Icon Link
	 * @param string $reference
	 * @return string Html Link
	 */
	public function render($reference) {
		if(substr($reference,0,4) == 'http') {
			$uri = $this->uri.$reference;
		} else {
			$uri = 'http://'.$reference;
		}
		return '<a href="'.$uri.'" target="_blank">
					<img src="'._ASSETS_.'css/images/icons/'.$this->icon_class.'" width="20" />
				</a>';
	}
}
\Fox\Dao::infos(
	Type::className(),
	new \Fox\Object\Info('ressource_source_types', \Fox\Databases::DB_APP)
);
\Fox\Dao::useZone(Type::className(),new \Fox\Dao\MemoryCacheZone(\Fox\Dao\MemoryCacheZone::PERIOD_FOREVER,Type::cacheDirectory()));